<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../../Templates/SubFolderTemplate.xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">
    <ui:define name="head-title">
        <title>View Raw Material Supplier | Merlion's ERP System</title>
    </ui:define>
     

    <ui:define name="content">
      
            <p:panel id="panel" header="View Raw Material Supplier"> 
                <p:ajaxStatus style="width:16px;height:16px;">   
                    <f:facet name="start">   
                        <p:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" /> 
                    </f:facet> 
 
                <f:facet name="complete">   
                        <h:outputText value="" />   
                    </f:facet>   
                </p:ajaxStatus>
                
                <h:form prependId="false">
                    <p:dataTable var="supplier" value="#{viewSupplier.suppliers}" paginator="true" rows="10"
                                 selection="#{viewSupplier.selectedSupplier}" emptyMessage="Cannot find supplier">
                        
                        <p:column selectionMode="single"/>

                        <p:column sortBy="#{supplier.supplierName}" filterBy ="#{supplier.supplierName}" >
                            <f:facet name="header">
                                <h:outputText value="Supplier Name "/>
                            </f:facet>
                            <h:outputText value="#{supplier.supplierName}"/>
                        </p:column>
                        
                        <p:column sortBy="#{supplier.supplierContactNo}"  >
                            <f:facet name="header">
                                <h:outputText value="Contact Number "/>
                            </f:facet>
                            <h:outputText value="#{supplier.supplierContactNo}"/>
                        </p:column>
                        
                         <p:column sortBy="#{supplier.supplierEmail}"  >
                            <f:facet name="header">
                                <h:outputText value="Email Address "/>
                            </f:facet>
                            <h:outputText value="#{supplier.supplierEmail}"/>
                        </p:column>                       
                        
                        <f:facet name="footer">
                            <p:commandButton value="View" image="ui-icon ui-icon-search" update="display1 display2" oncomplete="supplierDialog.show()"/>
                            
                            <p:commandButton value="Delete" image="ui-icon ui-icon-close" update="display3 display4" oncomplete="supplierDeleteDialog.show()"/>

                        </f:facet>

                    </p:dataTable>
                    
                    <p:dialog header="Supplier Detail" widgetVar="supplierDialog" resizable="true" 
                              width="600" showEffect="clip" hideEffect="fold">
                        <h:panelGrid id="display1" columns="2" cellpadding="4">
                            
                            <h:outputText value="Supplier Name:"/>
                            <h:outputText value="#{viewSupplier.selectedSupplier.supplierName}"/>
                            
                            <h:outputText value="Supplier Address:"/>
                            <h:outputText value="#{viewSupplier.selectedSupplier.supplierAddress}"/>
                            
                            <h:outputText value="Supplier Postcode:"/>
                            <h:outputText value="#{viewSupplier.selectedSupplier.supplierPostcode}"/>
                            
                            <h:outputText value="Supplier Contact Number:"/>
                            <h:outputText value="#{viewSupplier.selectedSupplier.supplierContactNo}"/>
                            
                            <h:outputText value="Supplier Email:"/>
                            <h:outputText value="#{viewSupplier.selectedSupplier.supplierEmail}"/>
                            
                        </h:panelGrid>
                        
                        <p:dataTable var="supplyItem" value="#{viewSupplier.selectedSupplier.supplyItemList}"
                                     dynamic="true" paginator="true" emptyMessage="No Raw Material Type" id="display2">
                            <p:column sortBy="#{supplyItem.supplyItemId}">
                                <f:facet name="header">
                                    <h:outputText value="Supply Item ID"/>
                                </f:facet>
                                <h:outputText value="#{supplyItem.supplyItemId}"/>
                            </p:column>

                            <p:column sortBy="#{supplyItem.supplyItemType}">
                                <f:facet name="header">
                                    <h:outputText value="Type"/>
                                </f:facet>
                                <h:outputText value="#{supplyItem.supplyItemType}"/>
                            </p:column> 
                            
                            <p:column sortBy="#{supplyItem.supplyItemPrice}">
                                <f:facet name="header">
                                    <h:outputText value="Price"/>
                                </f:facet>
                                <h:outputText value="#{supplyItem.supplyItemPrice}"/>
                            </p:column>
                        
                        </p:dataTable> 
                        
                        <p:commandButton value="Edit" image="ui-icon ui-icon-pencil" actionListener="#{viewSupplier.editSupplier}">
                             <f:attribute name="selectedSupplier" value="#{supplier}"/>
                        </p:commandButton>
                    </p:dialog>
                    
                    <p:dialog header="Supplier Detail" widgetVar="supplierDeleteDialog" width="600" height="400" resizable="true"
                              showEffect="explode" hideEffect="explode">
                        <h:panelGrid id="display3" columns="2" cellpadding="4">
                            <h:outputText value="Supplier Name:"/>
                            <h:outputText value="#{viewSupplier.selectedSupplier.supplierName}"/>
                            
                            <h:outputText value="Supplier Address:"/>
                            <h:outputText value="#{viewSupplier.selectedSupplier.supplierAddress}"/>
                            
                            <h:outputText value="Supplier Postcode:"/>
                            <h:outputText value="#{viewSupplier.selectedSupplier.supplierPostcode}"/>
                            
                            <h:outputText value="Supplier Contact Number:"/>
                            <h:outputText value="#{viewSupplier.selectedSupplier.supplierContactNo}"/>
                            
                            <h:outputText value="Supplier Email:"/>
                            <h:outputText value="#{viewSupplier.selectedSupplier.supplierEmail}"/>                           
                        </h:panelGrid>
                        
                        <p:dataTable var="supplyItem" value="#{viewSupplier.selectedSupplier.supplyItemList}"
                                     dynamic="true" paginator="true" emptyMessage="No Raw Material Type" id="display4">
                            <p:column sortBy="#{supplyItem.supplyItemId}">
                                <f:facet name="header">
                                    <h:outputText value="Supply Item ID"/>
                                </f:facet>
                                <h:outputText value="#{supplyItem.supplyItemId}"/>
                            </p:column>

                            <p:column sortBy="#{supplyItem.supplyItemType}">
                                <f:facet name="header">
                                    <h:outputText value="Type"/>
                                </f:facet>
                                <h:outputText value="#{supplyItem.supplyItemType}"/>
                            </p:column> 
                            
                            <p:column sortBy="#{supplyItem.supplyItemPrice}">
                                <f:facet name="header">
                                    <h:outputText value="Price"/>
                                </f:facet>
                                <h:outputText value="#{supplyItem.supplyItemPrice}"/>
                            </p:column>
                        </p:dataTable> 
                        
                        <p:spacer height="35"/>
                        <p:commandButton value="Confirm Delete" actionListener="#{viewSupplier.deleteSupplier}" oncomplete="supplierDeleteDialog.hide()">
                            <f:attribute name="selectedSupplier" value="#{supplier}"/>
                        </p:commandButton>
                        <p:commandButton value="Cancel" onclick="supplierDeleteDialog.hide()" type="button"/>
                        <p:messages />
                        
                    </p:dialog>
                                      
  
                    
                   
                </h:form>
            </p:panel>
   
    </ui:define>

</ui:composition>
